<template>
	<view>
		
		<view class="inptop">
			<view class="">
				QQ:
			</view>
			<input focus="digit" v-model="qq" placeholder="修改QQ" class="inpp" type="text">
		</view>
		
		
		<view class="">
			<button @click="submitpassword">
				完成
			</button>
		</view>
		<view class="logtop">
			<view class="tipc">
				绑定qq符合
				<view class="f-active-color">
					《xxxAPP服务协议》
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import $http from '@/common/api/request.js'
	export default {
		data() {
			return {
				qq:"",
				userid:0,
				rules:{
					qq:{
						rule:/^.+$|^.{1,50}$/,
						msg: "qq不符合"
					}
				}
			};
		},
		methods:{
			//校验规则:
			validate(key){
				let bool =true;
				if(! this.rules[key].rule.test(this[key])){
					uni.showToast({
						title:this.rules[key].msg,
						icon:"none"
					})
					bool = false;
					return bool;
				}
				return bool
			},
			submitpassword(){
				if(! this.validate("qq")){
					return
				}
				
				$http.request({
					url: "/editqq",
					method: "POST",
					data: {
						qq: this.qq,
						id:this.userid
					}
				}).then((res) => {
					this.qq = ''
					uni.navigateBack({
						delta:1
					})
				}).catch(() => {
				
				})
			}
		},
		onLoad(e) {
			this.userid =e.id
		}
	}
</script>

<style lang="scss">
	.inptop {
		display: flex;
		padding: 20rpx 30rpx;

		.inpp {
			width: 80%;
		}
	}

	.telbot {
		margin-top: 30rpx;
		display: flex;
		justify-content: center;

		.contel {
			padding: 10rpx;
			border: 1rpx solid #282c35;
			border-radius: 40rpx;
			width: 80%;
			text-align: center;
			background-color: #2db0ff;
			color: #fcfefe;
		}
	}

	.tipc {
		margin-top: 10rpx;
		text-align: center;
		font-size: 26rpx;
		color: #c8c8c8;
	}
</style>